//
//  AppNetworkingManager+UserMananer.m
//  OANetworkManager
//
//  Created by TFAppleWork-Summer on 2018/2/9.
//  Copyright © 2018年 GuoRui. All rights reserved.
//

#import "AppNetworkingManager+UserMananer.h"

@implementation AppNetworkingManager (UserMananer)

+(AppBaseRequest *)userUpdateWithAvatarURL:(NSString *)url
                                      desc:(NSString *)desc
                                  complete:(OANetworkingObjectBlock)complete{
    
    NSDictionary *param = @{@"avatarURL":url,
                            @"desc":desc
                            };
    return [self startRequestWithParams:param
                                   path:@"user/update"
                     responseObjectPath:@""
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              BOOL isSuccess = NO;
                              if (error == nil) {
                                  isSuccess = YES;
                              }
                              if (complete) {
                                  complete(@(isSuccess),error);
                              }
                          }];
    
}

+(AppBaseRequest *)verifyPwdWithPwd:(NSString *)pwd
                           complete:(OANetworkingObjectBlock)complete{
    NSDictionary * param = @{@"password":pwd};
    return [self startRequestWithParams:param
                                   path:@"user/verifyPwd"
                     responseObjectPath:@""
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              BOOL isSuccess = NO;
                              if (error == nil) {
                                  isSuccess = YES;
                              }
                              if (complete) {
                                  complete(@(isSuccess),nil);
                              }
                            
                          }];
}

+(AppBaseRequest *)updatePwdWithPwd:(NSString *)password
                              phone:(NSString *)phone
                           complete:(OANetworkingObjectBlock)complete{
    NSDictionary *param ;
    if (phone == nil )
    {// 修改密码
        param = @{@"password" : password};
    }
    else
    {// 忘记密码
        param = @{@"password" : password,
                  @"phone" : phone
                  };
    }
    return [self startRequestWithParams:param
                                   path:@"user/updatePwd"
                     responseObjectPath:@"data"
                  popoverProgressString:nil
               handleErrorAutomatically:OANETWORKMANAGERSHOWHUD
                          responseBlock:^(id response, NSError *error) {
                              BOOL isSuccess = NO;
                              if (error == nil) {
                                  isSuccess = YES;
                              }
                              if (complete) {
                                  complete(@(isSuccess),error);
                              }
                          }];
}

@end
